// RawFlushRequest.h
//

#ifndef __RAWFLUSHREQUEST_H__
#define __RAWFLUSHREQUEST_H__

#include "base/Entity.h"
#include "base/Request.h"
#include "util/Pool.h"
#include "util/Logger.h"

class RawFlushRequest : public Request {
  public:
    NEW_DELETE_OPERATORS_H(RawFlushRequest,Request);
    /**
       a start of 0 means we want to flush all of memory
    */
    RawFlushRequest(Entity* src, Entity* dest, VA start, size_t length) :
        Request(src, dest, 1),
        _start(start),
        _length(length)
    { };
    virtual ~RawFlushRequest() { };
    bool isGlobal () {
        return _start == 0;
    }
    VA getStart () {
        return _start;
    }
    size_t getLength () {
        return _length;
    }
    bool inBounds (VA addr, size_t len) {
        if (isGlobal()) {
            return true;
        }
        // if end of arguments is before start, we aren't in bounds
        if (addr+len < _start) {
            return false;
        }
        // if start of arguments is after end start, we aren't in bounds
        if (addr >= _start+_length) {
            return false;
        }
        // we are in bounds for flushing
        return true;
    }
  private:
    VA _start;
    size_t _length;
    
};

#endif // __RAWFLUSHREQUEST_H__
